home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7187 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.magg.net!news
  2. From: n4mwd@magg.net (Dennis Hawkins)
  3. Newsgroups: comp.lang.c,comp.lang.c++,comp.os.ms-windows.programmer.misc,comp.os.msdos.programmer,comp.programming,comp.windows.ms.programmer
  4. Subject: Re: Date Arithmetic
  5. Date: Thu, 22 Feb 1996 05:47:04 GMT
  6. Organization: M.A.G. Information Services (MAGG.NET)
  7. Message-ID: <4ggsj3$1fg@dopey.magg.net>
  8. References: <4g19kp$640@tracy.protocom.com> <jrs.2754.000A7444@dclf.npl.co.uk>
  9. NNTP-Posting-Host: wpb-133.magg.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. jrs@dclf.npl.co.uk (Dr John Stockton  NPL UK) wrote:
  13.  
  14. >In article <4g19kp$640@tracy.protocom.com> "Michael J. Karas" <mkaras@pclink.com> writes:
  15.  
  16. >>I am working on an algorithm for a laser marking machine that writes
  17. >>expiration delays on to food product boxes. The algorithm needs to 
  18. >>be able to add NNN days to todays date in the fastest manner possible
  19. >>without using any floating point arithmetic. I could use help from anyone
  20.  
  21. This shouldn't be a big deal.  There are several algorithims to handle
  22. this.  The best one depends on the range of NNN days.  If it is just a
  23. couple of weeks then add it by brute force to the month.  If NNN can
  24. go to 999 then you are probably better off converting todays date into
  25. a julian or an integer that represents the number of days since your
  26. machine was put on line.  Then just add the days like you would any
  27. other integer.  Then convert it back again.  Dates can be tricky, you
  28. just need to do a lot of testing to make sure they work ok though.
  29.  
  30.  
  31. Dennis Hawkins
  32. n4mwd@amsat.org
  33.  
  34.